import 'package:ati_package/core/routes/app_routes.dart';
import 'package:ati_package/core/utils/ati_assets.dart';
import 'package:ati_package/pages/common/ati_scaffold.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../../core/utils/ati_color.dart';
import '../../../../core/utils/ati_font.dart';
import '../../../common/widgets/ati_common_btn.dart';
// import '../../../common/widgets/ati_no_data.dart';

class UserAddressView extends StatefulWidget {
  const UserAddressView({super.key});

  @override
  State<UserAddressView> createState() => _UserAddressViewState();
}

class _UserAddressViewState extends State<UserAddressView> {
  @override
  Widget build(BuildContext context) {
    return AtiScaffold(
      title: '地址管理',
      body: Column(
        children: [
          // AtiNoDataWidget(),
          _buildAddressListWidget(),
          AtiCommonBtn(
            onPressed: () {
              Get.toNamed(AtiAppRoutes.userAddAddress);
            },
            titleStr: '+新增地址',
            margin: EdgeInsets.symmetric(horizontal: 38.r, vertical: 32.r),
          ),
        ],
      ),
    );
  }

  _buildAddressListWidget() {
    return Flexible(
      child: Container(
        margin: EdgeInsets.only(left: 16.r, right: 16.r),
        child: ListView.builder(
          itemCount: 3,
          itemBuilder: (context, index) {
            return buildItem();
          },
        ),
      ),
    );
  }

  buildItem() {
    return Container(
      padding: EdgeInsets.only(
        top: 16.r,
        bottom: 12.r,
        left: 16.r,
        right: 16.r,
      ),
      margin: EdgeInsets.only(bottom: 12.r),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8.r),
      ),

      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              Container(
                // height: 17.r,
                // width: 20.r,
                padding: EdgeInsets.symmetric(vertical: 2.5.r, horizontal: 5.r),
                decoration: BoxDecoration(
                  color: Color(0xFF009E53),

                  borderRadius: BorderRadius.circular(2.r),
                ),
                child: Text(
                  '默认',
                  style: TextStyle(
                    fontSize: AtiFont.font10,
                    color: AtiColor.textHLColor1,
                  ),
                ),
              ),
              SizedBox(width: 5.r),
              Text(
                '中国 I 青海省海南藏族自治州同德县黄河',
                style: TextStyle(
                  fontSize: AtiFont.font13,
                  color: AtiColor.textColor1,
                  fontWeight: FontWeight.w600,
                ),
              ),
            ],
          ),
          SizedBox(height: 8.r),
          Row(
            children: [
              Text(
                '王琪 130****3356备份',
                style: TextStyle(
                  fontSize: AtiFont.font12,
                  color: Color(0xFF666666),
                ),
              ),
              Spacer(),
              Image.asset(
                width: 17.5.r,
                AtiAssets.userAddressDel,
                package: 'ati_package',
              ),
              SizedBox(width: 16.r),
              Image.asset(
                width: 17.5.r,
                AtiAssets.userAddressEdit,
                package: 'ati_package',
              ),
            ],
          ),
        ],
      ),
    );
  }
}
